@extends('layouts.main')

@section('title', '编辑指标数据')

@section('content')
<h3>@yield('title')</h3>
<div class="btn-group" role="group">
  	<a href="{{ action('BusinessData\InvoiceTargetKeyProductController@index') }}" class="btn btn-primary">返回列表</a>
</div>

<form class="form-horizontal" method="post" action="{{ action('BusinessData\InvoiceTargetKeyProductController@update', $model) }}">
    @csrf
    @method('PUT')

    <div class="form-group">
		<label for="year" class="col-sm-2 control-label">年度</label>
		<div class="col-sm-6">
			<select class="form-control" id="year" name="year">
				@for($i = 2020; $i <= 2030; $i++)
				<option value="{{ $i }}" @if(old('year') == $i || $model->year == $i) selected @endif>{{ $i }}</option>
				@endfor
			</select>
			@if($errors->first('year'))
			<p class="help-block error">{{ $errors->first('year') }}</p>
			@endif
		</div>
    </div>

    <div class="form-group">
		<label for="sales_region_code" class="col-sm-2 control-label">销售大区</label>
		<div class="col-sm-6">
			<select class="form-control" id="sales_region_code" name="sales_region_code">
				@foreach($sales_regions as $sales_region)
				<option value="{{ $sales_region->code }}" @if(old('sales_region_code') == $sales_region->code || $model->sales_region_code == $sales_region->code) selected @endif>{{ $sales_region->code.' --- '.$sales_region->code_desc }}</option>
				@endforeach
			</select>
			@if($errors->first('sales_region_code'))
			<p class="help-block error">{{ $errors->first('sales_region_code') }}</p>
			@endif
		</div>
    </div>

    <div class="form-group">
		<label for="category_key_product_id" class="col-sm-2 control-label">重点产品分类</label>
		<div class="col-sm-6">
			<select class="form-control" id="category_key_product_id" name="category_key_product_id">
				@foreach($category_key_products as $value)
				<option value="{{ $value->id }}" @if(old('category_key_product_id') == $value->id || $model->category_key_product_id == $value->id) selected @endif>{{ $value->name }}</option>
				@endforeach
			</select>
			@if($errors->first('category_key_product_id'))
			<p class="help-block error">{{ $errors->first('category_key_product_id') }}</p>
			@endif
		</div>
    </div>

	<div class="form-group">
		<label for="quantity" class="col-sm-2 control-label">开票指标(台数)</label>
		<div class="col-sm-3">
			<input class="form-control" id="quantity" name="quantity" placeholder="请输入开票指标(台数)" value="{{ old('quantity', $model->quantity) }}">
			@if($errors->first('quantity'))
			<p class="help-block error">{{ $errors->first('quantity') }}</p>
			@endif
		</div>
    </div>

    <div class="form-group">
		<div class="col-sm-offset-2 col-sm-10">
			<button type="submit" class="btn btn-primary">提交</button>
		</div>
    </div>
</form>

@endsection